package com.hopes.bizz.risk.setting.vo;

import cn.hutool.core.collection.CollectionUtil;
import com.hopes.bizz.risk.setting.entity.RiskConfigLsEntity;
import com.hopes.bizz.risk.setting.entity.RiskConfigScEntity;
import com.hopes.boss.admin.api.entity.SysDictItem;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author yumr
 * @ProjectName bizz
 * @Description LEC 辨识对象
 * @time 2023/7/21 13:08
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class RiskLsIdentifyVO implements Serializable {

    private static final long serialVersionUID = -2181079082067118706L;

    /**
     * LEC  L-事故发生可能性等设置
     */
    private List<RiskConfigLVO> riskLsLList;

    /**
     * LEC E-
     */
    private List<RiskConfigScVO> riskLsSList;

    /**
     * 风险等级
     */
    private List<SysDictItem> riskLevelList;

    /**
     * LS
     */
    private List<RiskConfigLsEntity> riskLsConfigList;


    public static List<RiskConfigScVO> entity2VO(List<RiskConfigScEntity> collection) {
        if (CollectionUtil.isEmpty(collection)) {
            return new ArrayList<>();
        }
        return collection.stream().map(item -> {
            final RiskConfigScVO riskConfigScVO = new RiskConfigScVO();
            BeanUtils.copyProperties(item, riskConfigScVO);
            riskConfigScVO.setCasualtyDesc("(" + item.getLevelValue() + ")" + item.getCasualtyDesc());
            return riskConfigScVO;
        }).collect(Collectors.toList());
    }

}
